#pragma once 
#include <iostream>
#include <ctime>
#include <cstdarg>

#define DEBUG   0
#define NORMAL  1
#define WARNING 2
#define ERROR   3
#define FATAL   4

const char* gLevelMap[5] = {
    "DEBUG",
    "NORMAL",
    "WARNING",
    "ERROR",
    "FATAL"
};

void logMessage(int level, const char *format, ...)
{
    time_t timeStamp = time(nullptr);
    struct tm *localTime = localtime(&timeStamp);   // 获取时间戳

    // 全局部分信息
    printf("%d-%d-%d, %02d:%02d:%02d, level:%d\n", localTime->tm_year, localTime->tm_mon, \
        localTime->tm_mday, localTime->tm_hour, localTime->tm_min, localTime->tm_sec);

    // 自定义部分信息
    va_list args;
    va_start(args, format);
    char message_buffer[1024];
    vsnprintf(message_buffer, 1024, format, args);
    va_end(args);
    printf("%s\n", message_buffer);
}